package com.hxexp.weixin.test;

import org.junit.Assert;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import com.hxexp.weixin.common.jsptag.CustomFunctions;
import com.hxexp.weixin.test.runner.JUnit4WithLogClassRunner;


/**
 * 自定义函数标签类测试
 * @author wang.bin
 *
 */
@RunWith(JUnit4WithLogClassRunner.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class CustomFunctionsTester {

    @Test
    public void testCase01() {
        String schType = "0";
        String expected = "固定班";
        String returnValue = CustomFunctions.getSchTypeName(schType);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase02() {
        String orderStatus = "0";
        String expected = "未支付";
        String returnValue = CustomFunctions.getOrderStatusName(orderStatus);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase03() {
        String state = "4";
        String expected = "退款失败";
        String returnValue = CustomFunctions.getTicketStateName(state);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase04() {
        String gender = "1";
        String expected = "先生";
        String returnValue = CustomFunctions.getGenderTitle(gender);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase05() {
        String dateFormat = "yyyy-MM-dd";
        String expected = "2016-03-18";
        String returnValue = CustomFunctions.getCurrentDate(dateFormat);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase06() {
        String date = "2016-04-13";
        int expected = 1;
        int returnValue = CustomFunctions.compareWithCurrentDate(date);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase07() {
        String version = "zg";
        String expected = "自贡汽车客运总站电子客票";
        String returnValue = CustomFunctions.getPageTitle(version);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase08() {
        String identificationType = "1";
        String expected = "身份证";
        String returnValue = CustomFunctions.getIdentificationTypeName(identificationType);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase09() {
        String identificationType = "1";
        String identificationNumber = "510502198401050098";
        String expected = "510502****0098";
        String returnValue = CustomFunctions.getHiddenIdentificationNumber(identificationNumber, identificationType);
        System.out.println(returnValue);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase10() {
        String passengerType = "1";
        String expected = "成人";
        String returnValue = CustomFunctions.getPassengerTypeName(passengerType);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase11() {
        String identificationType = "1";
        String identificationNumber = "510502198401050098";
        boolean expected = true;
        boolean returnValue = CustomFunctions.isIDCardNumber(identificationNumber, identificationType);
        Assert.assertEquals(expected, returnValue);
    }

    @Test
    public void testCase12() {
        Assert.assertEquals(true, CustomFunctions.isDisableStartCityInitial(""));
    }
}
